home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9264 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: druid.borland.com!usenet
  2. From: pete@borland.com (Pete Becker)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: MSVC++ 4.0 compiler really doesn't call subclassed virtual functions in this case.
  5. Date: 29 Feb 1996 16:46:42 GMT
  6. Organization: Borland International
  7. Message-ID: <4h4l9i$4fh@druid.borland.com>
  8. References: <4gnpf9$q8o@ccnet2.ccnet.com>
  9. NNTP-Posting-Host: pbecker.borland.com
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=ISO-8859-1
  12. X-Newsreader: WinVN 0.99.5
  13.  
  14. In article <4gnpf9$q8o@ccnet2.ccnet.com>, paulp@ccnet.com says...
  15. >
  16. >I've got this problem that I know is not my fault. I declare classes
  17. >   class A{
  18. >      virtual blah();
  19. >   };
  20. >
  21. >   class B:public A{
  22. >      virtual blah();
  23. >   };
  24. >
  25. >   B myB;
  26. >
  27. >And at runtime, calling myB.blah(); causes E:blah() to be called. The reason 
  28. I
  29. >know it is not my fault is because it goes away if I delete the object files 
  30. for
  31. >A and B and recompile. The first time after deleting the object files, the 
  32. bug
  33. >goes away, then the next compile (without re-deleting the obj files) the bug
  34. >comes back. Thus I can fix the problem by always deleting the obj files 
  35. before
  36. >compiling. 
  37. >
  38. >Has anybody else had this problem with VC++ 4.0? Is it related to incremental
  39. >compiling and linking?
  40. >
  41. >My guess is that if you compile the above example, code, you won't see this
  42. >problem, as in my case the classes aren't quite so simple, and only happen 
  43. for
  44. >some classes, and not for others.
  45.  
  46. That sort of problem typically comes up when you change the definition of a 
  47. class and then for some reason don't recompile all the source files that use 
  48. that definition. The old .OBJ files were built with the old definition, and 
  49. the new ones were built with the new definition. That's a recipe for disaster. 
  50. So check your build process. It is also possible that this is a result of 
  51. incremental compiling: if that isn't working right, it could easily produce 
  52. this sort of problem.
  53.     -- Pete
  54.  
  55.